<?php
 
my_component_load('list_kalender' , false);
my_component_load('testing' , false);   
my_component_load('a_kalkulasi' , false);   
my_component_load('a_tutup_bulan' );
$task = isset($_GET['task']) ? $_GET['task']: '';
$periode_id = isset($_GET['periode_id']) ? $_GET['periode_id']: '';
$schedule = isset($_GET['schedule']) ? $_GET['schedule']: 'false' ;
$periode_id=(int) $periode_id; 
//ADD LOADING	
	
	if($task =='kga'){ 
		$title="Kalkulasi tutup bulan absen";
		facebox_page('index.php?com='.$_GET['com'].'&periode_id='.$_GET['periode_id'].'&schedule='.$_GET['schedule'].'&task=tutup_bulan_all_page' , $title , 120	); 
	}elseif($task =='tutup_bulan_all_page'){
		$content = page_kalkulasi2(); 
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task =='tutup_bulan_all'){
		ini_set("max_execution_time","10000");
		header("Cache-Control: no-cache, must-revalidate"); 
		$periode_absen =get_periode_absen();
		if($periode_id < $periode_absen){
			echo 'PROSES GAGAL <br> Periode sudah berlalu' ;
			exit;
		}elseif($periode_id > $periode_absen){
			echo 'PROSES GAGAL <br> Data tidak tersedia' ;
			exit;
		}
		$query = "UPDATE opsi_seting SET value='{$_SESSION['user_id']}' WHERE name='kalkulasi'";
		my_query($query);
		
		tutup_bulan($schedule); 
		ini_set("max_execution_time","10000");
		
		$query = "UPDATE opsi_seting SET value='0' WHERE name='kalkulasi'";
		my_query($query);
		echo button_icon( 'check2.png' ,'')."<br/>Done !!";
		exit;
		
	}elseif($task =='create_schedule'){
		$periode_id =get_periode_absen();
		kalendar_shift_proses_update($periode_id  );
		my_direct('index.php?com=kalendar_shift');
		exit;
	}elseif($task =='update_absen_payroll'){  //untuk proses tanpa tutup bulan -> tidak ada di menu, jalankan di browser
		form_data_absen() ;
		exit;		
	}else{
		$pagename = "Tutup bulan absen";
		load_facebox_script();
		$content = form_pilih_periode(); 
	}
	generate_my_web($content, $pagename );
	exit;
//END ADD LOADING
my_direct($_SERVER['HTTP_REFERER']);